package com.roger.springcloudGreenwich.api;

import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.*;


import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/test/{option}")
    public String testGet(@PathVariable String option){
        System.out.println("接收到"+option+" get请求");
        Map<String , String> hp = new HashMap<>();
        hp.put("data", "success");
        return "success";
    }

    @PostMapping("/testPost")
    public String testPost(@RequestBody User user){
        System.out.println("接收到post请求");
        String username = user.getUsername();
        System.out.println(username);
        Map<String , String> hp = new HashMap<>();
        hp.put("data", "success");
        return "success";
    }


}

class User {
    Long id;
    String username;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
